﻿Public Class clsGBQXZJ
    Public Function insert(en As entity_gbqxzj) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= "INSERT INTO sf.b_gt_gbqxzj(factory_id , technology_id, oper_date, oper_type , type_value , clean_value , "
        sql &= "defect_value , cleaning_value , rust_value , check_value , ng_value , ng_reason , "
        sql &= "ng_solution, oper , update_time) "
        sql &= "VALUES ( ?, ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ?, ?, (SELECT CURRENT_TIMESTAMP(6)))"
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .factory_id, .technology_id, .oper_date, .oper_type, .type_value, .clean_value,
                                         .defect_value, .cleaning_value, .rust_value, .check_value, .ng_value, .ng_reason,
                                         .ng_solution, .oper)
        End With
        Return rtn
    End Function

    Public Function update(en As entity_gbqxzj) As Integer
        Dim sql As String = String.Empty
        Dim rtn As Integer
        sql &= " UPDATE sf.b_gt_gbqxzj SET oper_date = ?, oper_type = ?, type_value = ?, clean_value = ?, defect_value = ? "
        sql &= " , cleaning_value = ?, rust_value = ?, check_value = ?, ng_value = ?, ng_reason = ?, ng_solution = ? "
        sql &= " WHERE sys_id = ? "
        With en
            rtn = DBacs.ExecuteUpdateSql(sql, -1, .oper_date, .oper_type, .type_value, .clean_value, .defect_value,
                                         .cleaning_value, .rust_value, .check_value, .ng_value, .ng_reason, .ng_solution, .sys_id)
        End With
        Return rtn
    End Function

    Public Function selectBySysid(_sysid As String) As DataTable
        Dim szSql As String = "select a.*,b.requirement,b.control_point from sf.b_gt_gbqxzj a left join sf.t_mst_technology b on a.technology_id::integer = b.sys_id where a.factory_id=? and a.sys_id=?"
        Return DBacs.ExecuteSql(szSql, -1, "TS", _sysid)
    End Function

    Public Function getList(startTime As String, endTime As String) As DataTable
        Dim szSql As String = ""
        szSql &= "select * from sf.b_gt_gbqxzj "
        szSql &= " where 1=1 "
        If startTime <> "" Then
            szSql &= " and update_time >= '" + startTime + "'"
        End If
        If endTime <> "" Then
            szSql &= " and update_time <= '" + endTime + "'"
        End If
        Return DBacs.ExecuteSql(szSql, -1)
    End Function
End Class
